# -*- coding: utf-8 -*-
"""Mobile operations module for managing mobile entities."""

class UOMobiles:
    """A wrapper class for RAE's Mobiles module."""
    
    @staticmethod
    def FindByName(name):
        """Find mobile by name or list of names.
        
        Args:
            name: The name (str) or list of names (list[str]) of the mobile to find
            
        Returns:
            Mobile or None: The found mobile or None if not found
        """
        if not name:
            return None
        
        # If name is a list, try each name in order
        if isinstance(name, list):
            for n in name:
                npc = UOMobiles.FindByName(n)
                if npc:
                    return npc
            print(f"None of the NPCs in list {name} found")
            return None
        
        # Create a new filter instance
        filter = Mobiles.Filter()
        
        # Set up filter for NPC name
        filter.Name = name
        filter.Enabled = True
        
        # Apply filter to find NPC
        npc_list = Mobiles.ApplyFilter(filter)
        
        if npc_list and len(npc_list) > 0:
            npc = npc_list[0]  # Get the first matching NPC
            distance = Player.DistanceTo(npc)
            print(f"Found NPC {npc.Name} at distance {distance} tiles")
            return npc
        else:
            print(f"NPC {name} not found")
            return None 